<template>
  <li class="blog-item">
    <div class="blog-info">
      <div class="blog-info-top">
        <a class="word-count">
          字数：{{ data.content ? data.content.length : 0 }}
        </a>
        <span class="time">
          {{ $moment(data.createTime).fromNow() }}
        </span>
        <!--3表示热门加精选，2表示热门，1表示精选，0表示普通文章-->
        <span v-if="[1, 3].includes(data.importance)" class="sift mark">
          精
        </span>
        <span v-if="[1, 2].includes(data.importance)" class="hot mark">
          热
        </span>
        <span v-if="[4].includes(data.importance)" class="top mark">
          顶
        </span>
      </div>
      <div class="blog-info-title">
        <nuxt-link :to="'/edit/' + data.id">
          {{ data.title }}
        </nuxt-link>
      </div>
      <div class="blog-info-bottom">
        <a v-for="(innerItem, index) of data.tags" :key="index" class="tag">
          # {{ innerItem.name }}
        </a>
        <a
          v-if="currentRouteName === 'tempArticle'"
          class="iconfont el-icon-delete"
          @click="$emit('modifyArticleStatus', data.id, 'delete')"
        >
          删除
        </a>
        <a
          v-if="currentRouteName === 'tempArticle' && data.status === 'READY'"
          class="iconfont el-icon-check"
          @click="$emit('modifyArticleStatus', data.id, 'finish')"
        >
          发布
        </a>
        <nuxt-link
          v-if="currentRouteName === 'tempArticle' && data.status === 'TEMP'"
          class="iconfont el-icon-edit"
          :to="'/edit/' + data.id"
        >
          编辑
        </nuxt-link>
      </div>
    </div>
    <nuxt-link class="blog-cover" :to="'/edit/' + data.id">
      <img :src="data.article_img" alt="">
    </nuxt-link>
  </li>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      currentRouteName: this.$route.name
    }
  },
  computed: {
    userData() {
      return this.$store.state.user.userData
    }
  }
}
</script>

<style scoped lang="scss">
  @import "~assets/css/article/articleItem";
</style>
